package modules

import (
	"fmt"
	"github.com/allegro/bigcache/v3"
	"time"
)

type localCache struct {
	cache *bigcache.BigCache
}

var LocalCache localCache

func (b *localCache) New() *bigcache.BigCache {
	if b.cache != nil {
		return b.cache
	}

	var err error
	// 30分钟后删除
	b.cache, err = bigcache.NewBigCache(bigcache.DefaultConfig(30 * time.Minute))
	if err != nil {
		fmt.Println(err.Error())
	}
	return b.cache
}
